package com.ftg.learn.controller;

import com.ftg.learn.pojo.Qizu;
import com.ftg.learn.service.QizuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@CrossOrigin
@RequestMapping("/qizu")
public class QizuController {
    @Autowired
    QizuService qs;
    //查询全部
    @GetMapping("/show")
    public Map<String,Object> showall(int page,int limit){
        Map<String,Object> map = new HashMap<>();
        List<Qizu> list = qs.showall(page,limit);
        map.put("data",list);
        map.put("code",0);
        map.put("count", qs.getcount());
        map.put("msg","到哪里");
        return map;
    }
    //查一
    @PutMapping("/findone")
    public List<Qizu> findone(String qizu_id, String qizu_bt){
        return qs.findone(qizu_id,qizu_bt);
    }
    //添加
    @PostMapping("/add")
    public int add(Qizu qizu){
        return qs.add(qizu);
    }
    //删除
    @DeleteMapping("/delete/{qizu_id}")
    public int delete(@PathVariable String qizu_id){
        return qs.delete(qizu_id);
    }
    //修改
    @PostMapping("/update")
    public int update(Qizu qizu){
        return qs.update(qizu);
    }
}












